<template>
  <div>
    <div class="mainbox">
      <div class="main-title">擅长方向</div>
      <div class="main-tab">
        <div class="main-tab-item">全部(<span>248</span>)</div>
        <div class="main-tab-item">血管瘤(<span>21</span>)</div>
        <div class="main-tab-item">白癜风(<span>80</span>)</div>
        <div class="main-tab-item">荨麻疹(<span>45</span>)</div>
        <div class="main-tab-item">痤疮(<span>96</span>)</div>
        <div class="main-tab-item">尿布疹(<span>6</span>)</div>
      </div>
      <!-- 询问内容 -->
      <div class="ask-content">
        <div
          v-for="(item, index) in tainer.a"
          :key="item.id"
          class="ask-content-items"
        >
          <img src="../../img/mh/3398348946228434991-22.png" alt="" />
          <span>{{ item.username }}</span>
          <div>{{ item.prob }}</div>
        </div>
        <div class="addbtn"><span @click="addcount">点击查看更多</span></div>
      </div>
      
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref, getCurrentInstance } from "vue";
let { proxy } = getCurrentInstance();
let tainer = ref({ a: [] });
let count = 2;
//得到用户id
let props = defineProps(["mainid"]);
// console.log(props.mainid);
onMounted(async () => {
  //请求问题表
  let res = await proxy.$axios("/getprob", {
    params: { did: props.mainid, count: count },
  });
  // tainer.value.a=res.data
  for (let i = 0; i < res.data.length; i++) {
    tainer.value.a.push(res.data[i]);
  }
  // console.log(res);
});

let addcount = async () => {
  //获取问题表长度
   let res0 = await proxy.$axios("/getproblen")
  //  console.log(res0);
   if (res0.data.length<=count) {
      alert("已经到底啦 别点了")
      return
   }
   
  count += 8;
  let res = await proxy.$axios("/getprob", {
    params: { did: props.mainid, count: count },
  });
  // tainer.value.a=res.data
   tainer.value.a.length=0
  for (let i = 0; i < res.data.length; i++) {
    tainer.value.a.push(res.data[i]);
  }
};
</script>

<style scoped lang="scss">
.mainbox {
  // width:400px ;
  //   height: 400px;
  //   background-color: yellow;

  .main-title {
    padding: 20px 0 10px;
    color: #333;
    font-weight: 600;
    font-size: 28px;
    // line-height: 1.09
  }
  .main-tab {
    // margin-bottom: -12px;
    padding: 20px 0 10px;
    background-color: #fff;

    .main-tab-item {
      display: inline-block;
      margin-bottom: 12px;
      padding: 8px 12px;
      margin-right: 22px;
      color: #4d4d4d;
      font-weight: 300;
      font-size: 14px;
      line-height: 1.14;
      background-color: #fafafa;
      border-radius: 4px;

      span {
        font-weight: 400;
      }
    }
  }
  .ask-content {
    // height: 100px;
    // background-color: yellow;
    color: #333;

    .ask-content-items {
      border-bottom: 1px solid #ebebeb;
      margin-bottom: 20px;
      padding-bottom: 20px;
      img {
        width: 25px;
        height: 25px;
        vertical-align: middle;
      }
      span {
        font-size: 17px;
        display: inline-block;
        vertical-align: middle;
        margin-left: 5px;
      }
      div {
        margin-top: 12px;
        color: #4d4d4d;
        width: 860px;
        word-break: break-all;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3; /* 这里是超出几行省略 */
        overflow: hidden;
      }
    }
  }
}

.addbtn {
  height: 30px;
  line-height: 30px;
  text-align: center;
  font-size: 14px;
  margin-bottom: 20px;
  margin-top: 30px;

  span {
    padding: 5px 15px;
    color: #00c792;
    background-color: #f5f5f5;
    border-radius: 15px;
    cursor: pointer;
    caret-color: transparent;
  }
}
</style>
